using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class RateThisApp : MonoBehaviour
{
	public static Delegate0Args onRateThisAppDialogDestroy;

	private Animator m_Animator;

	[SerializeField]
	private Text m_PhysicalGet;

	private bool m_RatingApp;

	public static RateThisApp instance
	{
		get;
		private set;
	}

	private void Awake()
	{
		instance = this;
		m_Animator = GetComponent<Animator>();
		m_PhysicalGet.text = 20.ToString();
	}

	private void Start()
	{
		RectTransform component = GetComponent<RectTransform>();
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
	}

	public void OnApplicationPause(bool pause)
	{
		if (!pause && m_RatingApp)
		{
			m_Animator.SetTrigger("Hide");
			StartCoroutine(PhysicalRewardShow());
		}
	}

	private IEnumerator PhysicalRewardShow()
	{
		yield return new WaitForSeconds(0.5f);
		TextDialog.Show(string.Format(HOLocalizationConfiguration.GetValue(351), 20));
		ConstantData.physical += 20;
		m_RatingApp = false;
	}

	private void OnDestroy()
	{
		if (onRateThisAppDialogDestroy != null)
		{
			onRateThisAppDialogDestroy();
		}
		onRateThisAppDialogDestroy = null;
	}

	public void Sure()
	{
		m_RatingApp = true;
		PlayerPrefs.SetInt("RateInterval", 40);
		Application.OpenURL("market://details?id=ccom.sportsgame.poolmaster.free");
	}

	public void Later()
	{
		m_Animator.SetTrigger("Hide");
	}

	public static void Show()
	{
		SupportTools.AddChild<RateThisApp>(GameManager.CurrentUIRoot.gameObject, "UI/RateThisApp");
	}
}
